/**
 * 地点相关API
 */
import { api } from '@/utils/request'
import type {
  ApiResponse,
  PaginatedResponse,
  Location,
  LocationQueryParams,
  LocationFormData
} from '@/types/api'

/**
 * 获取地点列表
 */
export function getLocations(params?: LocationQueryParams): Promise<PaginatedResponse<Location>> {
  return api.get('/locations', { params })
}

/**
 * 获取地点详情
 */
export function getLocationById(id: number): Promise<ApiResponse<Location>> {
  return api.get(`/locations/${id}`)
}

/**
 * 创建地点
 */
export function createLocation(data: LocationFormData): Promise<ApiResponse<Location>> {
  return api.post('/locations', data)
}

/**
 * 更新地点
 */
export function updateLocation(id: number, data: Partial<LocationFormData>): Promise<ApiResponse<Location>> {
  return api.put(`/locations/${id}`, data)
}

/**
 * 删除地点
 */
export function deleteLocation(id: number): Promise<ApiResponse<null>> {
  return api.delete(`/locations/${id}`)
}

/**
 * 审核通过地点
 */
export function approveLocation(id: number): Promise<ApiResponse<Location>> {
  return api.put(`/locations/${id}/approve`)
}

/**
 * 拒绝地点
 */
export function rejectLocation(id: number): Promise<ApiResponse<Location>> {
  return api.put(`/locations/${id}/reject`)
}
